package com.baidu.day04;

public class User {
    //成员变量
    String userName;
    String password;

    public User (){
        this.userName = "root";
        this.password = "12345";
    }
    /**
     * 模拟用户登录
     * @param userName 用户名
     * @param password 密码
     */
    public void login(String userName,String password){
        //比较字符串相等时，尽量把一定不为空的字符串放在前面，避免空指针异常
        if(this.userName.equals(userName) && this.password.equals(password)) {
            System.out.println("登录成功，欢迎回来");
        }else{
            System.out.println("登录失败,用户名或密码错误");
        }
    }
}
